<template>
  <div class="colpoint-monitor">
    <aside class="aside">
      <div class="search-wrap" @click="openDia">
        <img class="img" src="./images/search.png" alt="" />
        <span>搜索</span>
      </div>
      <el-tree
        node-key="id"
        indent="20"
        :data="data"
        :props="defaultProps"
        @node-click="handleNodeClick"
      />
    </aside>
    <main class="main">
      <header class="header">
        <div class="title-wrap">
          <div class="title">
            <div class="line"></div>
            <div class="text">采集点实时监测</div>
          </div>
          <div class="time">
            <img src="./images/time.png" alt="" />
            <span class="name">更新时间:</span>
            <span class="val">2023-10-27 10:00:55</span>
          </div>
          <div class="btn">
            <button class="off">合闸</button>
            <button class="on">分闸</button>
          </div>
        </div>
        <div class="show-data">
          <div class="v">
            <div class="title">电压</div>
            <div class="msg">
              <div>A相电流：233.6v</div>
              <div>B相电压：234.1V</div>
              <div>C相电压：233.0V</div>
            </div>
          </div>
          <div class="i">
            <div class="title">电流</div>
            <div class="msg">
              <div>A相电流：41.4a</div>
              <div>B相电压：16.2a</div>
              <div>C相电压：24.3a</div>
            </div>
          </div>
          <div class="w">
            <div class="title">功率</div>
            <div class="msg">
              <div>有功功率：16.3kw</div>
              <div>无功功率：-2.8kvar</div>
              <div>频率：50.0hz</div>
            </div>
          </div>
          <div class="kw">
            <div class="title">功率因数</div>
            <div class="msg">
              <div>A相功率因数：1.000</div>
              <div>B相功率因数：1.000</div>
              <div>C相功率因数：1.000</div>
              <div>合相功率因数：1.000</div>
            </div>
          </div>
          <div class="q">
            <div class="title">电量</div>
            <div class="msg">
              <div>A相有功电量：26.3kW•h</div>
              <div>B相有功电量：13.0kW•h</div>
              <div>C相有功电量：13.0kW•h</div>
              <div>总有功电量：6012.2kW•h</div>
            </div>
          </div>
          <div class="hvf">
            <div class="title">电压谐波</div>
            <div class="msg">
              <div>A相电压谐波：2.0 %</div>
              <div>B相电压谐波：2.0 %</div>
              <div>C相电压谐波：2.0 %</div>
            </div>
          </div>
          <div class="a">
            <div class="title">电流谐波</div>
            <div class="msg">
              <div>A相电流谐波：59.0 %</div>
              <div>B相电流谐波：51.0 %</div>
              <div>C相电流谐波：56.0 %</div>
            </div>
          </div>
        </div>
      </header>

      <div class="content">
        <el-form :model="formData" :inline="true">
          <el-form-item label="日期">
            <el-date-picker
              v-model="formData.a"
              type="date"
              placeholder="请选择日期"
            />
          </el-form-item>
          <el-form-item>
            <el-button class="pre"
              ><el-icon class="el-icon--right"
                ><ArrowLeft color="#176FF9" /></el-icon
              >上一日
            </el-button>
            <el-button class="next"
              >下一日
              <el-icon class="el-icon--right"
                ><ArrowRight color="#176FF9"
              /></el-icon>
            </el-button>
          </el-form-item>
        </el-form>
        <div class="sel-wrap" @click="selPerature">
          <div class="v" :style="{ color: selType == 'v' ? '#176FF9' : '' }">
            电压
          </div>
          <div class="line"></div>
          <div class="i" :style="{ color: selType == 'i' ? '#176FF9' : '' }">
            电流
          </div>
          <div class="line"></div>
          <div
            class="apparent"
            :style="{ color: selType == 'apparent' ? '#176FF9' : '' }"
          >
            视在
          </div>
          <div class="line"></div>
          <div
            class="active-power"
            :style="{ color: selType == 'active-power' ? '#176FF9' : '' }"
          >
            有功
          </div>
          <div class="line"></div>
          <div
            class="reactive-power"
            :style="{ color: selType == 'reactive-power' ? '#176FF9' : '' }"
          >
            无功
          </div>
          <div class="line"></div>
          <div
            class="per"
            :style="{ color: selType == 'per' ? '#176FF9' : '' }"
          >
            温度
          </div>
          <div class="line"></div>
          <div
            class="electricity"
            :style="{ color: selType == 'electricity' ? '#176FF9' : '' }"
          >
            电量
          </div>
          <div class="line"></div>
          <div
            class="hvf"
            :style="{ color: selType == 'hvf' ? '#176FF9' : '' }"
          >
            电压谐波
          </div>
          <div class="line"></div>
          <div class="a" :style="{ color: selType == 'a' ? '#176FF9' : '' }">
            电压谐波
          </div>
        </div>
        <!-- <h3 class="h3">单位（℃）</h3> -->
        <div class="echart-wrap">
          <Echarts />
        </div>
      </div>
    </main>
    <SearchDia v-model:visible="dialogVisible" @serachDigSure="serachDigSure" />
  </div>
</template>
<script setup lang="ts">
import { Upload, ArrowRight, ArrowLeft } from "@element-plus/icons-vue";
import SearchDia from "./component/DiaSearch";
import { ref, reactive } from "vue";
import TitleName from "../../components/TitleName";
import Echarts from "./component/Echarts";
let search = ref("");
let pageSize = ref("10");
let total = ref(111);
let currentPage = ref(1);
let dialogVisible = ref(false);
let selType = ref("v");
let value1 = ref("");
let formData = reactive({});
const defaultProps = {
  children: "children",
  label: "label",
};
const selPerature = (e) => {
  let name = e.target.className;
  console.log(name, "name");
  if (
    (name != "v" &&
      name != "i" &&
      name != "apparent" &&
      name != "active-power" &&
      name != "reactive-power" &&
      name != "per" &&
      name != "electricity" &&
      name != "hvf" &&
      name != "a") ||
    name == selType.value
  ) {
    return;
  }

  selType.value = name;
};
const serachDigSure = () => {
  console.log("弹框确认");
};
const data = [
  {
    label: "Level one 1",
    children: [
      {
        label: "Level two 1-1",
        children: [
          {
            label: "Level three 1-1-1",
          },
        ],
      },
    ],
  },
  {
    label: "Level one 2",
    children: [
      {
        label: "Level two 2-1",
        children: [
          {
            label: "Level three 2-1-1",
          },
        ],
      },
      {
        label: "Level two 2-2",
        children: [
          {
            label: "Level three 2-2-1",
          },
        ],
      },
    ],
  },
  {
    label: "Level one 3",
    children: [
      {
        label: "Level two 3-1",
        children: [
          {
            label: "Level three 3-1-1",
          },
        ],
      },
      {
        label: "Level two 3-2",
        children: [
          {
            label: "Level three 3-2-1",
          },
        ],
      },
    ],
  },
];
const handleNodeClick = (data) => {
  console.log(data);
};

const andleSelectionChange = () => {};
const openDia = () => {
  dialogVisible.value = true;
};
</script>
<style lang="scss" scoped>
.colpoint-monitor {
  padding: 14px 17px 19px 13px;
  display: flex;
  box-sizing: border-box;
  overflow: hidden;
  .aside {
    height: calc(100vh - 19px - 130px);
    width: 272px;
    margin-right: 10px;
    background-color: #fff;
    padding: 31px 0 24px 17px;
    .search-wrap {
      display: flex;
      align-items: center;
      background: #ffffff;
      border: 1px solid #176ff9;
      border-radius: 5px;
      height: 42px;
      width: 239px;
      padding-left: 28px;
      margin-bottom: 24px;
      cursor: pointer;

      span {
        font-weight: 400;
        color: #176ff9;
        font-size: 19px;
        padding-left: 11px;
      }
      .img {
        width: 19px;
        height: 19px;
      }
    }
  }
  .main {
    height: calc(100vh - 19px - 130px);
    width: calc(100vw - 295px - 161px);
    /* background-color: #fff; */
    .header {
      background: #ffffff;
      height: 248px;
      width: 100%;
      padding-top: 15px;
      .show-data {
        width: 100%;
        display: flex;
        padding: 12px 16px 0 17px;
        justify-content: space-between;
        .v,
        .i,
        .w,
        .kw,
        .q,
        .hvf,
        .a {
          box-sizing: border-box;
          .title {
            width: 197px;
            height: 39px;
            background: #176ff9;
            font-size: 18px;
            font-weight: 500;
            color: #ffffff;
            line-height: 39px;
            text-align: center;
          }
          .msg {
            margin-top: 5px;
            width: 197px;
            height: 135px;
            background: #ededed;
            font-size: 16px;
            font-weight: 500;
            color: #333333;
            line-height: 32px;

            padding-top: 20px;
            text-align: center;
          }
        }
        .kw,
        .q {
          .msg {
            padding-top: 8px;
            line-height: 30px;
          }
        }
      }

      .title-wrap {
        display: flex;
        align-items: center;
        justify-content: space-between;
        .title {
          display: flex;
          align-items: center;
          .line {
            width: 6px;
            height: 23px;
            background: #176ff9;
            margin-left: 17px;
            margin-right: 10px;
          }
          .text {
            font-size: 24px;
            font-weight: bold;
            color: #333333;
          }
        }
      }
      .time {
        display: flex;
        align-items: center;
        img {
        }
        .name {
          font-size: 19px;
          font-weight: 500;
          color: #666666;
          margin: 0 9px 0 6px;
        }
        .val {
          font-size: 19px;
          font-weight: 500;
          color: #333333;
        }
      }
      .btn {
        button {
          margin-right: 18px;
          width: 87px;
          height: 33px;
          font-size: 17px;
          font-weight: 500;
          color: #ffffff;
        }
        .off {
          background: #176ff9;
        }
        .on {
          background: #fc4848;
        }
      }
    }

    .content {
      background: #ffffff;
      margin-top: 10px;
      /* width: ; */
      height: calc(100vh - 19px - 173px - 228px);
      position: relative;
      :deep(.el-form) {
        padding-top: 20px;
        padding-left: 40px;
        .el-form-item {
          margin-right: 8px !important;
        }
        .pre,
        .next {
          font-size: 18px;
          font-weight: 500;
          color: #333333;
          width: 91px;
          padding-left: 0;
          height: 33px;
          border: 1px solid #cccccc;
          border-radius: 3px;
          text-align: center;
          line-height: 33px;
        }
        .pre {
          padding-left: 0;
        }
        .next {
          padding-right: 0;
        }
      }
      .sel-wrap {
        width: 805px;
        height: 40px;
        border: 1px solid #cccccc;
        border-radius: 5px;
        padding: 0px 24px 0 27px;
        display: flex;
        justify-content: space-between;
        align-items: center;

        position: absolute;
        top: 16px;
        right: 16px;
        box-sizing: border-box;
        z-index: 999;
        div {
          font-size: 19px;
          font-weight: 500;
          color: #333333;
          cursor: pointer;
        }
        .temperature {
        }
        .line {
          width: 1px;
          height: 17px;
          background: #cccccc;
        }
        .humidity {
        }
      }
      .h3 {
        font-size: 20px;
        font-weight: 500;
        color: #333333;
        margin-left: 49px;
        margin-top: 20px;
        position: absolute;
        top: 60px;
        z-index: 999;
        left: -5px;
      }
      .echart-wrap {
        padding-top: 22px;
        /* height: 300px; */
      }
    }
  }
}
</style>
